/**
 * 初始化 vue-easytable 的封装
 *
 * @author liangbin
 */
		Vue.component('vtable-operation',{
			template:`
			<div>
			<v-table
                is-vertical-resize
                :vertical-resize-offset='60'
                is-horizontal-resize
                style="width:100%"
                :multiple-sort="false"
                :min-height="350"
                even-bg-color="#f2f2f2"
                :columns="columns"
                :table-data="tableData"
                row-hover-color="#eee"
                row-click-color="#edf7ff"
                :paging-index="(pageIndex-1)*pageSize">
            </v-table>
            <v-pagination v-on:page-change="pageChange" v-on:page-size-change="pageSizeChange" :total="total" :page-size="pageSize" :layout="['total', 'prev', 'pager', 'next', 'sizer', 'jumper']"></v-pagination>
        </div>
			`,
	        props:{
	        	tableData:{
	                type:Object
	            },
	            columns:{
	            	type:Array
	            },
	            pageIndex:{
	            	type:Number
	            },
	            pageSize:{
	            	type:Number
	            },
	            total:{
	            	type:Number
	            },
	            url:{
	            	type:String
	            }
	        },
			methods:{
			    loadData(){
			    	var _this = this
			    	this.isLoading = true;
			    	$.ajax({
			    		url:this.url,
			    		data:{"pageIndex":_this.pageIndex,"pageSize":_this.pageSize,"queryParam":JSON.stringify(_this.queryParam)},
			    		type:"GET",
			    		success:function(mydata){
			    			_this.isLoading = false;
			    			_this.total=Number(mydata.total);
			    			_this.tableData=mydata.list;
			    		},
			    		error:function(){
			    			_this.isLoading = false;
			    		}
			    	})
				},
				pageChange(pageIndex){
	                this.pageIndex = pageIndex;
	                this.loadData();
	            },
	            pageSizeChange(pageSize){
	               this.pageIndex = 1;
	               this.pageSize = pageSize;
	               this.loadData();
	            },
	            setQueryParam(key,value){
	            	this.queryParam[key]=value;
	            }
			},
			created(){
				this.loadData();
				var _this=this;
				document.onkeydown = function(e){
					if(e && e.keyCode==13){ // enter 键
						_this.loadData();
		            }
			    }
			}
			
		})
